package com.cskaoyan.day11;

public class OverrideTest {
    public static void main(String[] args) {
        Person p = new SouthPerson();
        if (p instanceof SouthPerson) {
            SouthPerson southPerson = ((SouthPerson) p);
            System.out.println("southPerson.salary = " + southPerson.salary);
            southPerson.swim();
        }
    }
}

class Person {
    String name;
    int age;

    void eat() {
        System.out.println("人都要吃饭");
    }
}

class SouthPerson extends Person {
    String name;
    int age;
    double salary;

    public void swim() {
        System.out.println("南方人游泳");
    }

    @Override
    void eat() {
        System.out.println("南方人喜欢吃米饭");
    }
}

class NorthPerson extends SouthPerson {
    String name;
    int age;
    double height;

    @Override
    void eat() {
        System.out.println("北方人喜欢吃面食");
    }
}